import { defineStore } from "pinia";
interface GoodsType {
  name: string;
  price: number;
}
export const useGoods = defineStore("goods", {
  state: () => {
    return {
      list: [
        { name: "商品1", price: 9999 },
        { name: "商品2", price: 999.9 },
        { name: "商品3", price: 99.99 },
        { name: "商品4", price: 9.999 },
      ],
    };
  },
  getters: {
    //写法1：
    // filterList(state) {
    //   return state.list.filter((item) => item.price < 100);
    // },
    // 写法2：
    filterList(): Array<GoodsType> {
      return this.list.filter((item) => item.price < 100);
    },
  },
});
